package com.example.mybatis.contorller;

import com.example.mybatis.domain.User;
import com.example.mybatis.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by linving on 2017/1/11.
 */
@RestController
@RequestMapping("/user")
public class UserContorller {

    @Autowired
    private UserMapper userMapper;

    @GetMapping("/id/{id}")
    public User getUserById(@PathVariable("id") Long id) {
        return userMapper.selectUserByXml(id);
    }

    @GetMapping("/name/{name}")
    public User getUserByName(@PathVariable("name") String name) {
        return userMapper.findByName(name);
    }

}
